package Vista;
import java.awt.event.ActionListener;
import java.util.Vector;

import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.ImageIcon;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.WindowConstants;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class CompraV extends javax.swing.JFrame {
	private JPanel panelcompra;
	private JLabel lblnombrei;
	private JLabel lblcodingr;
	private JLabel lblcaningre;
	private JComboBox cmbIngre;
	private JButton btncan;
	private JButton btnre;
	private JTextField txtcan;
	private JTextField txtcodin;
	private JTextField txtcodcompra;
	private JLabel lblCodComp;

	/**
	* Auto-generated main method to display this JFrame
	*/
		
	public CompraV() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			this.setTitle("Compra de Ingredientes");
			{
				panelcompra = new JPanel();
				getContentPane().add(panelcompra, "Center");
				panelcompra.setBounds(0, 0, 390, 270);
				panelcompra.setLayout(null);
				
				{
					lblnombrei = new JLabel();
					panelcompra.add(lblnombrei);
					lblnombrei.setText("Nombre:");
					lblnombrei.setLayout(null);
					lblnombrei.setBounds(65, 48, 69, 15);
					lblnombrei.setFont(new java.awt.Font("Bookman Uralic",2,14));
				}
				{
					btnre = new JButton();
					panelcompra.add(btnre);
					btnre.setLayout(null);
					btnre.setText("Registrar");
					btnre.setBounds(38, 196, 132, 53);
					btnre.setFont(new java.awt.Font("Bookman Uralic",2,12));
					btnre.setIcon(new ImageIcon(getClass().getClassLoader().getResource("Imagenes/cajareg.png")));
				}
				{
					lblcodingr = new JLabel();
					panelcompra.add(lblcodingr);
					lblcodingr.setText("Codigo de Ingrediente:");
					lblcodingr.setLayout(null);
					lblcodingr.setBounds(38, 92, 171, 15);
					lblcodingr.setFont(new java.awt.Font("Bookman Uralic",2,14));
				}
				{
					lblcaningre = new JLabel();
					panelcompra.add(lblcaningre);
					lblcaningre.setText("Cantidad:");
					lblcaningre.setLayout(null);
					lblcaningre.setBounds(65, 136, 75, 15);
					lblcaningre.setFont(new java.awt.Font("Bookman Uralic",2,14));
				}
				{
					txtcodin = new JTextField();
					panelcompra.add(txtcodin);
					txtcodin.setBounds(209, 90, 62, 22);
				}
				{
					txtcan = new JTextField();
					panelcompra.add(txtcan);
					txtcan.setBounds(147, 133, 115, 22);
				}
				{
					btncan = new JButton();
					panelcompra.add(btncan);
					btncan.setLayout(null);
					btncan.setText("Cancelar");
					btncan.setBounds(209, 196, 132, 53);
					btncan.setFont(new java.awt.Font("Bookman Uralic",2,12));
					btncan.setIcon(new ImageIcon(getClass().getClassLoader().getResource("Imagenes/48px-Crystal_Clear_action_stop.png")));
				}
				{
					lblCodComp = new JLabel();
					panelcompra.add(lblCodComp);
					lblCodComp.setText("Cod.Compra:");
					lblCodComp.setBounds(71, 17, 80, 15);
					lblCodComp.setFont(new java.awt.Font("Bitstream Charter",2,14));
				}
				{
					txtcodcompra = new JTextField();
					panelcompra.add(txtcodcompra);
					txtcodcompra.setBounds(158, 13, 51, 22);
				}
				{
					ComboBoxModel cmbIngreModel = 
						new DefaultComboBoxModel(
								new String[] { "Seleccione...", "" });
					cmbIngre = new JComboBox();
					panelcompra.add(cmbIngre);
					cmbIngre.setModel(cmbIngreModel);
					cmbIngre.setBounds(146, 45, 101, 22);
				}
			}
			pack();
			setSize(400, 300);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
	public void addListener(ActionListener actionListener) {
		btnre.addActionListener(actionListener);
		btncan.addActionListener(actionListener);		
	}
	public void Limpiar()
	{
		cmbIngre.setToolTipText("Seleccione...");
		txtcodin.setText("");
		txtcan.setText("");
		txtcodcompra.setText("");
	}
	public  String getcomboingre(){
		return cmbIngre.getToolTipText();
	}
	public String getcantidad(){
		return txtcan.getText();
	}
	public String getcodingre(){
		return txtcodin.getText();
	}
	public String getcodcompra(){
		return txtcodcompra.getText();
	}
	public void mensaje(String sms)
	{
		JOptionPane.showMessageDialog(this, sms);
     }
	public void LlenarCombo(Vector<String> vector)
	{
		ComboBoxModel cmbnombreIngre = new DefaultComboBoxModel(vector);
		cmbIngre.setModel(cmbnombreIngre);
	}
}
